package com.yukang.guahao.response;

public class R<T> {
   private int status;
   private String message;
   private T data;
   private long timestamp;

   public R() {
      this.timestamp = System.currentTimeMillis();
   }

   public static <T> R<T> success(T data) {
      R<T> resultData = new R<>();
      resultData.setStatus(200);
      resultData.setMessage("操作成功");
      resultData.setData(data);
      return resultData;
   }

   public static <T> R<T> fail(int code, String message) {
      R<T> resultData = new R<>();
      resultData.setStatus(code);
      resultData.setMessage(message);
      return resultData;
   }

   public int getStatus() {
      return status;
   }

   public void setStatus(int status) {
      this.status = status;
   }

   public String getMessage() {
      return message;
   }

   public void setMessage(String message) {
      this.message = message;
   }

   public T getData() {
      return data;
   }

   public void setData(T data) {
      this.data = data;
   }

   public long getTimestamp() {
      return timestamp;
   }

   public void setTimestamp(long timestamp) {
      this.timestamp = timestamp;
   }

}
